//
//  LSQPushTableViewCell.m
//  
//
//  Created by dllo on 15/9/24.
//
//

#import "LSQPushTableViewCell.h"
#import <Masonry.h>
@implementation LSQPushTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.title = [[UILabel alloc]init];
        [self addSubview:self.title];
        self.title.font = [UIFont boldSystemFontOfSize:23];
        
        self.content = [[UILabel alloc]init];
        [self addSubview:self.content];
        
        
        
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    
    //根据文字的大小,计算出文本的尺寸
    //还需要执行一个尺寸(375,0)
    //第三个参数,计算高度需要根据字体的哪个特征来确定
    
    NSDictionary *fontDic=[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:23],NSFontAttributeName, nil];
    CGRect rect = [self.title.text boundingRectWithSize:CGSizeMake(self.frame.size.width , 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:fontDic context:nil];
    
    self.title.frame=CGRectMake(10 , rect.size.height  + 20 , self.frame.size.width -  20, (rect.size.height + 20 ));
    
    self.title.numberOfLines = 0;

    
    NSDictionary *font=[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:17],NSFontAttributeName, nil];
    CGRect rect1 = [self.content.text boundingRectWithSize:CGSizeMake(self.frame.size.width , 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:font context:nil];
    
    //self.content.frame=CGRectMake(10 , rect1.size.height  + 20 , self.frame.size.width -  20, (rect.size.height + 20 ));
    
    [self.content mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self).with.offset(10);
        
        make.size.mas_equalTo(CGSizeMake(self.frame.size.width - 20, rect1.size.height + 20 ));
        

        make.top.equalTo(self.title).with.offset(25);
        
    }];
    
    self.content.numberOfLines = 0;

    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
